package com.android.memory;

import com.android.memory.R;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

public class Card extends ImageView {
 	
	// Status controls which image is visible
	public enum Status {HIDDEN,VISIBLE,MISSING};
	private Status status;
	private int imageId;
	
	public Card(Context context) {
		super(context);
		setStatus(Status.HIDDEN);
	}

	// Compare two cards images
	public boolean equals(Card c) {
		return this.imageId == c.imageId;
	}
	
	// Sets imageId for the card
	public void setImageId(int imageId) {
		this.imageId = imageId;
	}
	
	// Returns the cards' status
	public Status getStatus(){
		return this.status;
	}
	
	// Returns the ImageId of the card
	public int getImageId() {
		return imageId;
	}
	
	/*
	 * Set the status of the card 
	 * If the card is hidden the back of the card is shown
	 * If the card is visible the front of the card is shown
	 * If the card is missing the image is set to be transparent 
	 */
	public void setStatus(Status status){
		this.status = status;
		
		if(status == Status.HIDDEN){
			this.setImageResource(R.drawable.back);
		}
		if(status == Status.VISIBLE){
			this.setImageResource(imageId);
		}
		if(status == Status.MISSING){
			this.setAlpha(0);
			this.setClickable(false);
			this.setVisibility(View.INVISIBLE);
		}
		
	}
}
	
